package com.woniuxy.commons.request;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: Mr·Xiang
 * @create 2024-04-09 9:53
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResPage<T>{
    private Integer curPage;    // 当前页
    private Integer size;       // 页大小
    private Long total;         // 总条数
    private Integer totalPage;  // 总页数
    private T data;             // 数据

    // 将PageInfo信息解析封装成自己的page对象
    public ResPage(PageInfo<T> pageInfo){
        this.curPage = pageInfo.getPageNum();
        this.size = pageInfo.getPageSize();
        this.totalPage = pageInfo.getPages();
        this.total = pageInfo.getTotal();
        this.data = (T) pageInfo.getList();
    }
}
